package com.caiyouxi.boss.buser.service.impl;

import com.caiyouxi.boss.buser.mapper.SysLogMapper;
import com.caiyouxi.boss.buser.model.SysLog;
import com.caiyouxi.boss.buser.service.SysLogService;
import com.caiyouxi.common.bean.QueryParams;
import com.caiyouxi.common.bean.ResData;
import com.caiyouxi.common.cache.RedisService;
import com.caiyouxi.common.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SysLogServiceImpl extends BaseService implements SysLogService{

    @Autowired
    SysLogMapper sysLogMapper;
    @Autowired
    RedisService redisService;

    @Override
    public ResData get_log_info(SysLog bean) {

        return success(sysLogMapper.get_log_info(bean.getId()));
    }

    @Override
    public ResData get_log_list(SysLog bean) {

        Integer reids_page_size = Integer.parseInt( redisService.get("sys.pagesize").toString());
        bean.setPage_size(reids_page_size);

        QueryParams params = new QueryParams();
        params.setList(sysLogMapper.get_log_list(bean));
        params.setPage(bean.getPage());
        params.setTotal(sysLogMapper.get_total_count(bean));
        params.setPage_size(reids_page_size);
        return success(params);
    }

    @Override
    public ResData add_log(SysLog bean) {
        return success(sysLogMapper.add_log(bean));
    }
}
